//
//  FDMKindDetaileCollectionViewCell.m
//  Entertainment
//
//  Created by dllo on 16/4/21.
//  Copyright © 2016年 付冬梅. All rights reserved.
//

#import "FDMKindDetaileCollectionViewCell.h"
#import "FDMFindDetaileModel.h"

@interface FDMKindDetaileCollectionViewCell ()

@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UIImageView *titleImage;

@end
@implementation FDMKindDetaileCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.titleImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.titleImage];
        [self.titleImage release];
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel release];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.contentView.layer.borderWidth = 0.5;
    self.contentView.layer.borderColor = [UIColor grayColor].CGColor;
    self.contentView.layer.cornerRadius = 5;
    self.contentView.layer.masksToBounds = YES;
    [self.titleImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        make.left.equalTo(self.contentView.mas_left).with.offset(20);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
        make.width.mas_equalTo(@20);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        make.left.equalTo(self.titleImage.mas_left).with.offset(30);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
        make.width.mas_equalTo(@(CONTENTVIEW_WIDTH  - 80));
    }];
}

- (void)dealloc {
    [self.titleLabel release];
    [self.titleImage release];
    [self.findDetaileModel release];
    [super dealloc];
}

- (void)setFindDetaileModel:(FDMFindDetaileModel *)findDetaileModel {
    if (_findDetaileModel != findDetaileModel) {
        [_findDetaileModel release];
        _findDetaileModel = [findDetaileModel retain];
        [self.titleImage sd_setImageWithURL:[NSURL URLWithString:_findDetaileModel.coverPath] placeholderImage:PLACEHOLDER_IMAGE];
        self.titleLabel.text = _findDetaileModel.title;
    }
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
